#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int N = 3e5+5,mod = 998244353;
int n,k,q,a[N],x[N],y[N];
namespace sub1{
	int t[N];
	#define lowbit(x) (x&(-x)) 
	inline void add(int x,int v)
	{
		for(;x<=n;x+=lowbit(x))
			t[x]+=v;
	}
	inline int ask(int x)
	{
		int res = 0;
		for(;x;x-=lowbit(x)) res+=t[x];
		return res;
	}
	inline void main()
	{
		int ans = 0;
		for(int i = n;i;i--) (ans+=ask(a[i]))%=mod,add(a[i],1);
		cout<<ans<<'\n';
	}
}
namespace sub2{
	int t[2][N];
	#define lowbit(x) (x&(-x)) 
	inline void add(int x,int v,int op)
	{
		for(;x<=n;x+=lowbit(x))
			t[op][x]+=v;
	}
	inline int ask(int x,int op)
	{
		int res = 0;
		for(;x;x-=lowbit(x)) res+=t[op][x];
		return res;
	}
	inline int qpow(int x,int y)
	{
		x%=mod;
		int res = 1;
		while(y)
		{
			if(y&1) res = res*x%mod;
			y>>=1;
			x = x*x%mod;
		}
		return res;
	}
	inline void main()
	{
		int ans = 0;
		for(int i = n;i;i--)
		{
			int cnt = ask(a[i],0),sum = ask(a[i],1);
			(ans+=n*(n-1)/2*cnt-sum-cnt*i)%=mod;
			cnt = n-i-cnt,sum = ask(n,1)-sum;
			(ans+=sum+cnt*i)%=mod;
//			cout<<"x"<<i<<' '<<ans<<'\n';
			add(a[i],1,0),add(a[i],n-i,1);
		}
		cout<<ans*qpow(n*(n-1)/2,mod-2)%mod<<'\n';
		if(q==1) swap(a[x[1]],a[y[1]]),sub1::main();
	}
}
signed main()
{
	freopen("random.in","r",stdin);
	freopen("random.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>k>>q;
	for(int i = 1;i<=n;i++)
		cin>>a[i];
	for(int i = 1;i<=k;i++) cin>>x[i]>>y[i]; 
	if(k==0) sub1::main();
	else if(k==1) sub2::main();
	return 0;
}

